<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title> Insha - Css3 Responsive Sidebar Menu</title>

    <link href="static/css/css2.css" rel="stylesheet">
    <link href='static/css/boxicons.min.css' rel='stylesheet'>
    <link rel="stylesheet" href="static/css/insha-style.css">

</head>
<body>

<div class="main" id="app">
    <div class="sidebar">
        <div class="logo_content">
            <div class="logo">
                <div class="logo_name">
                    <a href="#">
                        <i class='bx bxs-bank'></i>
                        银行业务管理系统
                    </a>
                </div>
            </div>
            <i class='bx bx-menu' id="toggle-menu-btn"></i>
        </div>
        <ul class="nav_list">

            <li>
                <a href="online.html">
                    <i class='bx bx-yen'></i>
                    <span class="links_name">网上银行</span>
                </a>
                <span class="tooltip">网上银行</span>
            </li>
            <li>
                <a href="counter.html">
                    <i class='bx bxs-user-account'></i>
                    <span class="links_name">银行柜面</span>
                </a>
                <span class="tooltip">银行柜面</span>
            </li>

        </ul>

    </div>
    <div class="home_content">
        <div class="text">银行柜面</div>
        我是查询余额页面
        <div class="rg_layout1">
            <div class="rg_left">
                <p>查询余额</p>
                <p>BALANCE QUERY</p>

            </div>
            <div class="rg_center">
                <div class="rg_form">
                    <!--定义表单 form-->
                    <form action="#" method="">
                        <table id="tbe">
                            <tr>
                                <td class="td_left"><label for="idCard">银行卡号</label></td>
                                <td class="td_right"><input type="text" name="idCard" id="idCard"
                                                            placeholder="请输入银行卡号" v-model="bankNo" readonly></td>
                            </tr>
                            <tr>
                                <td class="td_left"><label for="password">密码</label></td>
                                <td class="td_right"><input type="password" name="password" id="password"
                                                            placeholder="请输入银行卡密码6位" v-model="payPassword"
                                                            @blur="pd1()"></td>
                            </tr>
                            <tr>
                                <td class="td_left"><label for="balance">您的余额为</label></td>
                                <td class="td_right"><input type="balance" name="balance" id="balance" v-model="balance"
                                                            readonly></td>
                            </tr>


                            <tr>
                                <td colspan="2" align="center"><input type="button" id="btn_sub" value="查询余额"
                                                                      @click="cm()"></td>
                            </tr>

                        </table>

                    </form>


                </div>

            </div>

            <button id="bn1" @click="back1()">返回</button>
        </div>
    </div>

</div>


<script src="static/js/scripts.js"></script>
<script src="static/js/vue.js"></script>
<script src="static/js/axios.min.js"></script>
<script>
    // window.onload = function () {


    //     var searchUrl = window.location.href;
    //     var searchData = searchUrl.split("="); //截取 url中的“=”,获得“=”后面的参数
    //     var searchText = decodeURI(searchData[1]); //decodeURI解码
    //     app.bankNo = searchText


    // }
    const app = new Vue({
        el: "#app",
        data: {
            bankNo: localStorage.getItem("bankNo"),
            payPassword: "",
            balance: "",
            yinhang: {
                bankNo: "",
                payPassword: ""
            },

        },
        methods: {
            back1() {
                location.href = "onlineindex.html"
            },
            cm() {
                let this_ = this;

                if (this_.bankNo != "" && this_.payPassword != "") {
                    axios
                        .get("http://localhost:8080/balance/setbalance?bankNo=" + this_.bankNo + "&payPassword=" + this_.payPassword)

                        .then(res => {
                            let code = res.data.code;
                            if (code == 200) {
                                alert("查询成功")
                                //参数待定
                                this_.balance = res.data.data
                                if (res.data.data < 1) {
                                    alert("余额不足，请及时充值！")
                                }
                            } else {
                                alert("卡号或密码错误，请重新输入")
                            }
                        })

                } else {
                    alert("以上信息不能为空")
                }


            },
            // ic() {
            //     if ((this.bankNo.length != 16 && this.bankNo.length != 17 && this.bankNo.length != 19) && this.bankNo != "") {
            //         let rule = new RegExp("(^([1-9]{1})(\d{16}|\d{17}\d{19})$)")
            //         if (rule.test(this.bankNo) == false) {
            //             alert("您的银行卡格式不正确，请重新输入")
            //         }

            //     }
            // },

            pd1() {

                if (this.payPassword != "") {

                    let rule = new RegExp("(^[0-9]*$)")
                    if (this.payPassword.length != 6) {
                        alert("您的密码格式不正确，请重新输入")
                        this.payPassword = "";
                    } else {
                        axios
                            .get("http://localhost:8080/balance/bankno?bankNo=" + this.bankNo + "&payPassword=" + this.payPassword)
                            .then((resp) => {
                                // alert(resp.data.data);

                            })
                    }

                }

            }

        }
    })
</script>

</body>
</html>
